package com.company.L_4_1;

import java.lang.reflect.Field;

/**
 * Created by vilen on 2015/3/28.
 */
public class ClassUtil_2{

    public static void printMessage(Object obj){
        /**
         * 成员变量也是对象
         */
        Class c = obj.getClass();
        Field[] fields = c.getFields();
        for (Field f: fields){
            //得到成员变量类型的类类型
            Class fieldType = f.getType();
            String fieldTypeName = fieldType.getName();
            String fieldName =  f.getName();
            System.out.println(fieldTypeName+ "," + fieldName);

        }
    }
}
